from shopping.models import Cart,Goods,User
from rest_framework import serializers


class UserSerializer(serializers.ModelSerializer):


    class Meta:
        model = User
        fields = '__all__'



class GoodsSerializer(serializers.ModelSerializer):

    class Meta:
        model = Goods
        fields = '__all__'


class CartSerializer(serializers.ModelSerializer):

    goods = GoodsSerializer(read_only=True)
    user = UserSerializer(read_only=True)
    user_id = serializers.IntegerField(write_only=True)
    goods_id = serializers.IntegerField(write_only=True)

    class Meta:
        model = Cart
        fields = '__all__'
